package com.ideyatech.errorhandling.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "USER_GROUP")
public class Group extends BaseEntity {

    @Column(name = "NAME")
    private String name;

    @OneToMany(mappedBy = "group")
    private List<User> members;

    @OneToMany(mappedBy = "group")
    private List<GroupAuthority> groupAuthorities;
    
    public Group() {
	members = new ArrayList<User>();
	groupAuthorities = new ArrayList<GroupAuthority>();
    }

    public String getName() {
	return name;
    }

    public void setName(String name) {
	this.name = name;
    }

    public List<User> getMembers() {
	return members;
    }

    public void setMembers(List<User> members) {
	this.members = members;
    }

    public List<GroupAuthority> getGroupAuthorities() {
	return groupAuthorities;
    }

    public void setGroupAuthorities(List<GroupAuthority> groupAuthorities) {
	this.groupAuthorities = groupAuthorities;
    }

    public void addMember(User member) {
	members.add(member);
    }

    public void addAuthority(GroupAuthority groupAuthority) {
	groupAuthorities.add(groupAuthority);
    }

}
